# -*- encoding: utf-8 -*-
# 
# Lúcuma
# Copyright © 2008 Diego Escalante Urrelo  <diegoe@gnome.org>
# 
# Licensed under the GNU General Public License Version 2
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor
# Boston, MA  02110-1301, USA.
# 

from django import template

register = template.Library()

def note_single(context):
    """
    Render a single Note.
    Takes the following context params:
        notes_tags_about: Show about whom is this Note.
        notes_tags_preview: Show a small preview of the Note body.
        notes_tags_date: Shows the Note dates (created and modified).
        notes_tags_tasks: List the Tasks replying to this Note.
            tags by default.
            tasks_tags_reply: Inherited for the rendered Tasks. Hides the
            replied to in the Task by default.

    """
    return {
        'note':                 context.get('note', None),
        'session':              context.get('session', None),
        'notes_tags_about':     context.get('notes_tags_about', True),
        'notes_tags_preview':   context.get('notes_tags_preview', True),
        'notes_tags_date':      context.get('notes_tags_date', True),
        'notes_tags_tasks':     context.get('notes_tags_tasks', True),
        'tasks_tags_reply':     context.get('tasks_tags_reply', False),
        }

def note_list_single(context):
    """
    Render a single Note for a list.
    Takes the same context params than note_single.
    """
    return {
        'note':                 context.get('note', None),
        'session':              context.get('session', None),
        'notes_tags_about':     context.get('notes_tags_about', False),
        'notes_tags_preview':   context.get('notes_tags_preview', True),
        'notes_tags_date':      context.get('notes_tags_date', True),
        'notes_tags_tasks':     context.get('notes_tags_tasks', False),
        }

register.inclusion_tag('note_note.html', takes_context=True)(note_single)
register.inclusion_tag('note_note.html', takes_context=True)(note_list_single)
